
#ifndef SpriteBatchItem_h
#define SpriteBatchItem_h

// CSharp includes.
#include <Typedef.h>
#include <Defines.h>

#include <System/Object.h>

// Xna includes.
#include "Vertices/VertexPositionColorTexture.h"
#include "../Color.h"
#include "Texture2D.h"
#include "SpriteEffects.h"

namespace Riccsson
{
	namespace Xna
	{
		namespace Framework
		{
			namespace Graphics
			{
				class SpriteBatchItem
				{
					public: GC_PTR<Texture2D> Texture;
					public: float Depth;

					//public: Riccsson::Xna::Framework::Rectangle DestinationRectangle; 
					//public: Riccsson::System::Nullable<Riccsson::Xna::Framework::Rectangle> SourceRectangle;
					//public: Riccsson::Xna::Framework::Color Color;
					//		
					//public: float Rotation;
					//public: Riccsson::Xna::Framework::Vector2 Origin;
					//public: Riccsson::Xna::Framework::Graphics::SpriteEffects Effect;
							
					public: VertexPositionColorTexture vertexTL;
					public: VertexPositionColorTexture vertexTR;
					public: VertexPositionColorTexture vertexBL;
					public: VertexPositionColorTexture vertexBR;

					public: SpriteBatchItem ()
					{
						vertexTL = VertexPositionColorTexture();
						vertexTR = VertexPositionColorTexture();
						vertexBL = VertexPositionColorTexture();
						vertexBR = VertexPositionColorTexture();            
					}
					
					public: void Set ( float x, float y, float w, float h, Color color, Vector2 texCoordTL, Vector2 texCoordBR )
					{
						vertexTL.Position.X = x;
						vertexTL.Position.Y = y;
						vertexTL.Position.Z = Depth;
						vertexTL.color = color;
						vertexTL.TextureCoordinate.X = texCoordTL.X;
						vertexTL.TextureCoordinate.Y = texCoordTL.Y;            
					
						vertexTR.Position.X = x+w;
						vertexTR.Position.Y = y;
						vertexTR.Position.Z = Depth;
						vertexTR.color = color;
						vertexTR.TextureCoordinate.X = texCoordBR.X;
						vertexTR.TextureCoordinate.Y = texCoordTL.Y;
					
						vertexBL.Position.X = x;
						vertexBL.Position.Y = y+h;
						vertexBL.Position.Z = Depth;
						vertexBL.color = color;
						vertexBL.TextureCoordinate.X = texCoordTL.X;
						vertexBL.TextureCoordinate.Y = texCoordBR.Y;
					
						vertexBR.Position.X = x+w;
						vertexBR.Position.Y = y+h;
						vertexBR.Position.Z = Depth;
						vertexBR.color = color;
						vertexBR.TextureCoordinate.X = texCoordBR.X;
						vertexBR.TextureCoordinate.Y = texCoordBR.Y;
					}
					
					public: void Set ( float x, float y, float dx, float dy, float w, float h, float sin, float cos, Color color, Vector2 texCoordTL, Vector2 texCoordBR )
					{
						// TODO, Should we be just assigning the Depth Value to Z?
						// According to http://blogs.msdn.com/b/shawnhar/archive/2011/01/12/spritebatch-billboards-in-a-3d-world.aspx
						// We do.
						vertexTL.Position.X = x+dx*cos-dy*sin;
						vertexTL.Position.Y = y+dx*sin+dy*cos;
						vertexTL.Position.Z = Depth;
						vertexTL.color = color;
						vertexTL.TextureCoordinate.X = texCoordTL.X;
						vertexTL.TextureCoordinate.Y = texCoordTL.Y;
					
						vertexTR.Position.X = x+(dx+w)*cos-dy*sin;
						vertexTR.Position.Y = y+(dx+w)*sin+dy*cos;
						vertexTR.Position.Z = Depth;
						vertexTR.color = color;
						vertexTR.TextureCoordinate.X = texCoordBR.X;
						vertexTR.TextureCoordinate.Y = texCoordTL.Y;
					
						vertexBL.Position.X = x+dx*cos-(dy+h)*sin;
						vertexBL.Position.Y = y+dx*sin+(dy+h)*cos;
						vertexBL.Position.Z = Depth;
						vertexBL.color = color;
						vertexBL.TextureCoordinate.X = texCoordTL.X;
						vertexBL.TextureCoordinate.Y = texCoordBR.Y;
					
						vertexBR.Position.X = x+(dx+w)*cos-(dy+h)*sin;
						vertexBR.Position.Y = y+(dx+w)*sin+(dy+h)*cos;
						vertexBR.Position.Z = Depth;
						vertexBR.color = color;
						vertexBR.TextureCoordinate.X = texCoordBR.X;
						vertexBR.TextureCoordinate.Y = texCoordBR.Y;
					}
				};
				
				inline bool operator == (const SpriteBatchItem& a, const SpriteBatchItem& b)
				{
					throw;
				}
			}
		}
	}
}

#endif
